// index.js
const app = getApp();
Page({
    data: {
        articleList: [],
        url: '',
  
    },


    // 客服
    openChat() {
        wx.openCustomerServiceChat({
            corpId: 'ww5fbc1f6d9285c922',
            extInfo: {
                url: 'kfcc457337dd64f4734'
            },
            success(res) {
                console.log('成功打开客服会话', res);
            },
            fail(err) {
                console.error('打开客服会话失败', err);
            }
        });
    },

    // 跳转到文章列表页面
    goartileList(e) {
        const articleId = e.currentTarget.dataset.id;
        const articleTypeId = e.currentTarget.dataset.typeid;
        // 进行页面跳转
        wx.navigateTo({
            url: `/pages/index/artileList/artileList?id=${articleId}&typeId=${articleTypeId}`,
            success: function (res) {
                // 通过 eventChannel 向被打开页面传送数据
                res.eventChannel.emit('artileList', {
                    articleId: articleId,
                    articleTypeId: articleTypeId
                })
            }
        })
    },
    onLoad(options) {
        const app = getApp();
        this.setData({
            url: app.globalData.URL
        });
        let that = this;
        wx.request({
            url: that.data.url + '/article/selectAll?pageNum=1&pageSize=3',
            success(resp) {
                console.log(resp.data.data.list);
                that.setData({
                    articleList: resp.data.data.list
                });
            },
        })
    }
});